package com.hnas.eCard.service.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.hnas.eCard.dao.SaleCardOrderDetailDao;
import com.hnas.eCard.orm.SaleCardOrderDetail;
import com.hnas.eCard.service.SaleCardOrderDetailService;
import com.hnas.eCard.service.dto.DTOSaleCardOrderDetail;

@Component("saleCardOrderDetailService")
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class SaleCardOrderDetailServiceImpl implements SaleCardOrderDetailService{

	@Autowired
	private SaleCardOrderDetailDao saleCardOrderDetailDao;

	@Override
	public SaleCardOrderDetail saveOrUpdate(DTOSaleCardOrderDetail dto) {
		return this.saleCardOrderDetailDao.saveOrUpdate(dto);
	}

	@Override
	public SaleCardOrderDetail findByOrderNo(String orderNo) {
		return this.saleCardOrderDetailDao.findByOrderNo(orderNo);
	}

	@Override
	public DTOSaleCardOrderDetail findDTOByOrderNo(String orderNo) {
		SaleCardOrderDetail detail = this.saleCardOrderDetailDao.findByOrderNo(orderNo);
		DTOSaleCardOrderDetail dto = new DTOSaleCardOrderDetail();
		BeanUtils.copyProperties(detail, dto);
		return dto;
	}
}
